<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCaCustomers extends \App\Utils\CreateMigration
{
    function columns(Blueprint $table)
    {
        $table->unsignedTinyInteger('consultation_type')->default(0)->comment(' 咨询类型 1、未成年咨询@AB trust');
        $table->string('name')->default('')->comment('挂号人姓名');
        $table->unsignedInteger('age')->default(0)->comment('年龄');
        $table->string('real_name')->nullable('')->comment('真实姓名 zname');
        $table->timestamp('hf_time')->nullable()->comment('下次回访时间');
        $table->unsignedTinyInteger('gender')->default(1)->comment('性别 2：女；1：男；3：保密@AA');
        $table->string('mobile')->nullable('')->comment('联系电话');
        $table->string('weixin')->nullable('')->comment('微信号');
        $table->string('qq')->nullable('')->comment('qq号');
        $table->string('phone')->nullable('')->comment('座机');//座机
        $table->timestamp('yy_time')->nullable()->comment('预约日期');

        $table->unsignedBigInteger('source_id')->default(0)->comment('来源媒体');//来源媒体
        $table->unsignedBigInteger('consultation_way_id')->default(0)->comment('咨询方式');//咨询方式
        $table->unsignedBigInteger('medical_id')->default(0)->comment('话务员');//话务员
        $table->unsignedBigInteger('yy_doctor_id')->default(0)->comment('预约医生编号');
        $table->unsignedBigInteger('province_id')->default(0)->comment('省编号');
        $table->unsignedBigInteger('city_id')->default(0)->comment('市编号');
        $table->string('address')->nullable('')->comment('地址');
        $table->unsignedBigInteger('custom_service_id')->default(0)->comment('咨询客服用户编号');//
        $table->timestamp('fb_time')->nullable()->comment('发病时间');
        $table->decimal('cost_money')->nullable()->comment('费用');


        $table->string('source_site')->nullable()->comment('来源网站');
        $table->string('source_ip')->nullable()->comment('来源IP');
        $table->string('source_entry')->nullable()->comment('来源入口');
        $table->string('source_consulting_page')->nullable()->comment('咨询页面');//成永久身份ID
        $table->string('source_search_keywords')->nullable()->comment('搜索关键词');
        $table->string('source_matching_keywords')->nullable()->comment('匹配关键词');
        $table->string('gm_words')->nullable()->comment('购买词');
        $table->unsignedBigInteger('creator_id')->default(0)->comment('创建人用户编号');

        $table->text('medical_history')->nullable()->comment('就诊史');
        $table->text('disease_desc')->nullable()->comment('病情描述');
        $table->longText('swt')->nullable()->comment('商务通内容');
        $table->text('remark')->nullable()->comment('其他备注');
        $table->longText('disease_data')->nullable()->comment('疾病数据');
        $table->longText('visit_data')->nullable()->comment('回访数据');
        $table->longText('appointment_loss_reason_data')->nullable()->comment('预约流失原因@AD');
        $table->longText('arrived_loss_reason_data')->nullable()->comment('到院流失原因@AF');
        $table->unsignedBigInteger('jz_doctor_id')->default(0)->comment('就诊医生');
        $table->timestamp('jz_time')->nullable()->comment('就诊时间');
        $table->unsignedBigInteger('jz_guide_doctor_id')->default(0)->comment('接待导医');
        $table->unsignedTinyInteger('stage')->default(1)->comment('@AE 1症状,2咨询,3检查,4治疗,5康复');
        $table->timestamp('tady_yy_time')->nullable()->comment('预约日期是在什么时候操作的');
        $table->unsignedBigInteger('hospital_id')->default(0)->comment('医院编号');
        $table->unsignedTinyInteger('status')->default(0)->comment('状态@AC');
//        $table->string('customer_code')->default(1)->comment('客户编码');
//        $table->date('birthday')->nullable('')->comment('生日');
//        $table->string('profession')->nullable('')->comment('职业');
//        $table->unsignedTinyInteger('marital_status')->default(0)->comment('婚姻状况 2:未婚；1：已婚;3:保密');
//        $table->string('idcard')->nullable('')->comment('身份证');
//        $table->unsignedTinyInteger('is_type')->default(0)->comment('院内，咨询');
//        $table->string('code', 50)->nullable()->comment('业务编码');
//        $table->unsignedBigInteger('department_id')->default(0)->comment('科室编号');
//        $table->unsignedBigInteger('disease_id')->default(0)->comment('病种编号');
//        $table->timestamp('consultation_time')->nullable()->comment('咨询时间，什么时候和客服联系的');
//        $table->string('yy_code')->nullable()->comment('预约号');
//        $table->string('yy_remark')->nullable()->comment('预约号');
//        $table->text('chat_record')->nullable()->comment('聊天记录');
//        $table->text('chat_file')->nullable()->comment('聊天文件');
//        $table->unsignedBigInteger('source_site_id')->nullable()->comment('来源站点编号');

//        $table->unsignedTinyInteger('is_hospitalized')->default(0)->comment('是否住院 1：未住院；2：住院');
//        $table->decimal('how_much_money')->nullable()->default(0)->comment('是否消费1：未消费；2消费');
//        $table->unsignedBigInteger('come_way_id')->default(0)->comment('来院方式');
//        $table->string('consultation_remark')->nullable()->comment('咨询备注');
//        $table->string('doctor_remark')->nullable()->comment('医生备注');
//        $table->string('input_ip')->nullable()->comment('其他备注');
//        $table->unsignedBigInteger('member_id')->default(0)->comment('会员ID');

//        $table->unsignedBigInteger('old_id')->default(0)->comment('old');
//        $table->unsignedBigInteger('is_self_booking')->default(0)->comment('是否自助挂号(0:不是；1:是)');
//        $table->unsignedBigInteger('allot_status')->default(0)->comment('1：未分配;2:已分配（已被领取）');
//        $table->text('swt2')->nullable()->comment('商务通内容');
//        $table->longText('disease_data')->nullable()->comment('疾病显示');//
//        $table->text('species')->nullable()->comment('疾病显示');
//        $table->text('weixinlog')->nullable()->comment('微信聊天记录');
//        $table->text('phonelog')->nullable()->comment('微信聊天记录');

//
//        $table->unsignedTinyInteger('trust')->default(0)->comment(' 咨询 1、未成年咨询@AB');
//        $table->unsignedInteger('zy_time')->default(0)->comment('住院时间');
//        $table->unsignedInteger('cy_time')->default(0)->comment('出院时间');
//        $table->unsignedInteger('ls_time')->default(0)->comment('流失时间');
//        $table->unsignedBigInteger('okswt')->default(0);
//        $table->unsignedBigInteger('okwx')->default(0);
//        $table->string('coordinate')->default(0);
//        $table->string('zhu_time')->default(0);
//        $table->string('chu_time')->default(0);
//        $table->string('zyday')->default(0);
        $table->unique(['hospital_id', 'mobile', 'deleted_at'], 'unique_mobile');
    }

    function tableInfo()
    {
        return ['ca__customers', '预约咨询-客户列表'];
    }

    public function getData()
    {
        \App\Utils\MigrationUtil::addCodes('AA', '性别', [
            1 => '男',
            2 => '女',
            3 => '保密',
        ]);
        \App\Utils\MigrationUtil::addCodes('AB', '咨询类型', [
            1 => '未成年咨询',
            2 => '家属咨询',
            3 => '本人咨询',
            4 => '其他',
        ]);
        \App\Utils\MigrationUtil::addCodes('AC', '咨询状态', [
            1 => '登记',
            2 => '预约',
            3 => '到诊',
            6 => '线上已到',
            4 => '过期',
        ]);
        \App\Utils\MigrationUtil::addCodes('AD', '预约流失原因', [
            1 => '预约（临时有变）',
            2 => '预约（路途太远）',
        ]);

        \App\Utils\MigrationUtil::addCodes('AF', '到院流失原因', [
            1 => '到院（服务不好）',
            2 => '到院（环境太差）',
        ]);

        \App\Utils\MigrationUtil::addCodes('AE', '咨询进度', [
            1 => '症状',
            2 => '咨询',
            3 => '检查',
            4 => '治疗',
            5 => '康复',
        ]);
        return parent::getData();
    }
}
